<? 
	$title="User List"; 
	$pageid="4";
	$accessid=",a10,";


	require("required/dbconnect.php"); 
	require("required/function.php");
	require("required/header.php");
	
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<?
	if(empty($_GET['action']))
	{
		$msg="";
	}
	else
	{
		switch($_GET['action'])
		{
			case "1":
				$msg="<div class='dw_failed'>Email Not Found!</div>";
				break;
			case "2":
				$msg="<div class='dw_failed'>Member Card Number Not Found</div>";
				break;
			case "3":
				$msg="<div class='dw_success'>Data Updated</div>";
				break;	
			default:
				$msg="";
				break;
		}
		
		echo "<script>displayMsg('divMsg')</script>";	
	}
	
	
	$get_info=mysql_query("select * from os_contactinfo where id=1");
	
	$a=mysql_fetch_array($get_info,MYSQL_ASSOC);
	
	
	
	
	checkAccess("allow_branch_sales_add",1);
?>
<script language="javascript">
				
function checkExist() {
	var details = document.getElementById("details").value;
	var details_type = document.getElementById("details_type").value;
	
	if(details!=""){
		if(details_type=="email")
		{
			changeContent('required/js/checkOfflineExist.php?field=email&showName=&value='+details,'divResult');
		}
		else{
			changeContent('required/js/checkOfflineExist.php?field=member_card&showName=&value='+details,'divResult');
		}
	}
}

function updateMemberCard(memberCardNumber){
	
	document.getElementById('member_card').value=memberCardNumber;
	
}


function frmValidate(frm1)
{
	if(document.frm1.email.value=="")
	{
		alert("Please enter your email");
		document.frm1.email.focus();
		return false;
	}
	
	if (document.frm1.email.value!="")
	{
		var x = document.frm1.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)==false)
		{ 
			alert('Please enter a valid email address');
			document.frm1.email.focus();
			return false;
		}
	}
	
	if (document.frm1.receipt_number.value!="")
	{
		alert("Please enter receipt number");
		document.frm1.receipt_number.focus();
		return false;
	}
	
	if (document.frm1.amount.value!="")
	{
		alert("Please enter purchase amount");
		document.frm1.purchase_amount.focus();
		return false;
	}
		
	
}

</script>
<script language="JavaScript" type="text/javascript" src="required/js/goAjax.js"></script>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">
<tr>
	
	<td valign="top">
			<div id="divMsg"><?= $msg ?></div>
			<form action="offline_purchase_add2.php" method="post" onsubmit="return frmValidate(this)" name="frm1">
			<table width="100%">
			
				<tr>
					<td colspan="3" class="title">
				
					<strong>Create Offline Purchase</strong>
					
					</td>
				</tr>
				<tr valign="top">
					<td>
                    Please enter the customer's email address or membership card number to search for an existing record<br />
                    <input type="text" value="" name="details" id="details" maxlength="100" size="30"  onBlur="checkExist(); return false;">
                        <select name="details_type" id="details_type"  onchange="checkExist(); return false;">
                            <option value="email">Email</option>
                            <option value="member_card">Member Card</option>
                        </select>
                    <div id="divResult"></div>
                    </td>
			  	</tr>
			 	
				<td width="16%">
                	
				  <input type="checkbox" name="register_new" value="1">Register New Membership<br />		
				  <input type="submit" value="Submit" class="button" name="btnsubmit">
				</td>
			</table>
			</form>
		</td>
	</tr>
	
	
</table>
<? require("required/footer.php"); ?>

